<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        li {
            list-style: none;
        }
        .tabsbox {
            width: 600px;
            margin: 80px auto 0;
            border: 1px solid #000;
        }
        .tab-head {
            display: flex;
            border-bottom: 1px solid #000;
            position: relative;
        }
        #add {
            display: block;
            position: absolute;
            right: 0;
            top: 0;
            line-height: 32px;
            width: 64px;
            text-align: center;
            color: blue;
            text-decoration: none;
        }
        .tab-head li {
            flex: 0 0 100px;
            line-height: 32px;
            text-align: center;
            position: relative;
        }
        .tab-head li.active {
            color: #f00;
            border-color: #f00;
        }
        .tab-head li .remove {
            display: block;
            position: absolute;
            right: 0;
            top: 0;
            color: #f00;
            line-height: 1;
            cursor: pointer;
        }
        .tab-cont {
            padding: 30px;
        }
        .tab-cont section {
            display: none;
        }
        .tab-cont section.active {
            display: block;
        }
    </style>
</head>
<body>
    <div class="tabsbox" id="tab">
        <ul class="tab-head">
            <li class="active"><span class="tit">tab-1</span> <span class="remove">x</span></li>
            <li><span class="tit">tab-2</span> <span class="remove">x</span></li>
            <li><span class="tit">tab-3</span> <span class="remove">x</span></li>
            <a href="javascript:;" id="add">添加</a>
        </ul>
        <article class="tab-cont">
            <section class="active">内容1</section>
            <section>内容2</section>
            <section>内容3</section>
        </article>
    </div>
    <script src="tab.js"></script>
</body>
</html>